<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            let arr = [0, 1, 2, 3, 4, 6, 7, 8, 9];
            var missingNumber = function (nums) {
                let left = 0,
                    right = nums.length - 1;
                while (left <= right) {
                    let mid = (left + right) >> 1;
                    console.log(mid);
                    if (nums[mid] == mid) {
                        left = mid + 1;
                    } else if (nums[mid] > mid) {
                        right = mid - 1;
                    }
                }
                return left;
            };
            console.log(missingNumber(arr));
        </script>
    </body>
</html>
